package com.dhh.nutrition.vo;

import java.math.BigDecimal;

public class Food {
	private int type = 0;
	private int serving = 100;
	private String NDB_No;
	private String Shrt_Desc;
	private double Water;
	private double Energ_Kcal;
	private double Protein;
	private double Lipid_Tot;
	private double Ash;
	private double Carbohydrt;
	private double Fiber_TD;
	private double Sugar_Tot;
	private double Calcium;
	private double Iron;
	private double Magnesium;
	private double Phosphorus;
	private double Potassium;
	private double Sodium;
	private double Zinc;
	private double Copper;
	private double Manganese;
	private double Selenium;
	private double Vit_C;
	private double Thiamin;
	private double Riboflavin;
	private double Niacin;
	private double Panto_Acid;
	private double Vit_B6;
	private double Folate_Tot;
	private double Folic_Acid;
	private double Food_Folate;
	private double Folate_DFE;
	private double Choline_Tot;
	private double Vit_B12;
	private double Vit_A_IU;
	private double Vit_A_RAE;
	private double Retinol;
	private double Alpha_Carot;
	private double Beta_Carot;
	private double Beta_Crypt;
	private double Lycopene;
	private double Lut_Zea;
	private double Vit_E;
	private double Vit_D_mcg;
	private double ViVit_D_IU;
	private double Vit_K;
	private double FA_Sat;
	private double FA_Mono;
	private double FA_Poly;
	private double Cholestrl;
	private double GmWt_1;
	private String GmWt_Desc1;
	private double GmWt_2;
	private String GmWt_Desc2;
	private double Refuse_Pct;
	private String FdGrp_Cd;	
	
	public String getNDB_No() {
		return NDB_No;
	}
	public void setNDB_No(String nDB_No) {
		NDB_No = nDB_No;
	}
	public String getShrt_Desc() {
		return Shrt_Desc;
	}
	public void setShrt_Desc(String shrt_Desc) {
		Shrt_Desc = shrt_Desc;
	}
	public double getWater() {
		return perValue(Water) ;
	}
	public void setWater(double water) { 
		Water = water;
	}
	public double getEnerg_Kcal() {
		return perValue(Energ_Kcal) ;
	}
	public void setEnerg_Kcal(double energ_Kcal) {
		Energ_Kcal = energ_Kcal;
	}
	public double getProtein() {
		return perValue(Protein) ;
	}
	public void setProtein(double protein) {
		Protein = protein;
	}
	public double getLipid_Tot() {
		return perValue(Lipid_Tot) ;
	}
	public void setLipid_Tot(double lipid_Tot) {
		Lipid_Tot = lipid_Tot;
	}
	public double getAsh() {
		return perValue(Ash) ;
	}
	public void setAsh(double ash) {
		Ash = ash;
	}
	public double getCarbohydrt() {
		return perValue(Carbohydrt) ;
	}
	public void setCarbohydrt(double carbohydrt) {
		Carbohydrt = carbohydrt;
	}
	public double getFiber_TD() {
		return perValue(Fiber_TD) ;
	}
	public void setFiber_TD(double fiber_TD) {
		Fiber_TD = fiber_TD;
	}
	public double getSugar_Tot() {
		return perValue(Sugar_Tot) ;
	}
	public void setSugar_Tot(double sugar_Tot) {
		Sugar_Tot = sugar_Tot;
	}
	public double getCalcium() {
		return perValue(Calcium) ;
	}
	public void setCalcium(double calcium) {
		Calcium = calcium;
	}
	public double getIron() {
		return perValue(Iron) ;
	}
	public void setIron(double iron) {
		Iron = iron;
	}
	public double getMagnesium() {
		return perValue(Magnesium) ;
	}
	public void setMagnesium(double magnesium) {
		Magnesium = magnesium;
	}
	public double getPhosphorus() {
		return perValue(Phosphorus) ;
	}
	public void setPhosphorus(double phosphorus) {
		Phosphorus = phosphorus;
	}
	public double getPotassium() {
		return perValue(Potassium) ;
	}
	public void setPotassium(double potassium) {
		Potassium = potassium;
	}
	public double getSodium() {
		return perValue(Sodium) ;
	}
	public void setSodium(double sodium) {
		Sodium = sodium;
	}
	public double getZinc() {
		return perValue(Zinc) ;
	}
	public void setZinc(double zinc) {
		Zinc = zinc;
	}
	public double getCopper() {
		return perValue(Copper) ;
	}
	public void setCopper(double copper) {
		Copper = copper;
	}
	public double getManganese() {
		return perValue(Manganese) ;
	}
	public void setManganese(double manganese) {
		Manganese = manganese;
	}
	public double getSelenium() {
		return perValue(Selenium) ;
	}
	public void setSelenium(double selenium) {
		Selenium = selenium;
	}
	public double getVit_C() {
		return perValue(Vit_C) ;
	}
	public void setVit_C(double vit_C) {
		Vit_C = vit_C;
	}
	public double getThiamin() {
		return perValue(Thiamin) ;
	}
	public void setThiamin(double thiamin) {
		Thiamin = thiamin;
	}
	public double getRiboflavin() {
		return perValue(Riboflavin) ;
	}
	public void setRiboflavin(double riboflavin) {
		Riboflavin = riboflavin;
	}
	public double getNiacin() {
		return perValue(Niacin) ;
	}
	public void setNiacin(double niacin) {
		Niacin = niacin;
	}
	public double getPanto_Acid() {
		return perValue(Panto_Acid) ;
	}
	public void setPanto_Acid(double panto_Acid) {
		Panto_Acid = panto_Acid;
	}
	public double getVit_B6() {
		return perValue(Vit_B6) ;
	}
	public void setVit_B6(double vit_B6) {
		Vit_B6 = vit_B6;
	}
	public double getFolate_Tot() {
		return perValue(Folate_Tot) ;
	}
	public void setFolate_Tot(double folate_Tot) {
		Folate_Tot = folate_Tot;
	}
	public double getFolic_Acid() {
		return perValue(Folic_Acid) ;
	}
	public void setFolic_Acid(double folic_Acid) {
		Folic_Acid = folic_Acid;
	}
	public double getFood_Folate() {
		return perValue(Food_Folate) ;
	}
	public void setFood_Folate(double food_Folate) {
		Food_Folate = food_Folate;
	}
	public double getFolate_DFE() {
		return perValue(Folate_DFE) ;
	}
	public void setFolate_DFE(double folate_DFE) {
		Folate_DFE = folate_DFE;
	}
	public double getCholine_Tot() {
		return perValue(Choline_Tot) ;
	}
	public void setCholine_Tot(double choline_Tot) {
		Choline_Tot = choline_Tot;
	}
	public double getVit_B12() {
		return perValue(Vit_B12) ;
	}
	public void setVit_B12(double vit_B12) {
		Vit_B12 = vit_B12;
	}
	public double getVit_A_IU() {
		return perValue(Vit_A_IU) ;
	}
	public void setVit_A_IU(double vit_A_IU) {
		Vit_A_IU = vit_A_IU;
	}
	public double getVit_A_RAE() {
		return perValue(Vit_A_RAE) ;
	}
	public void setVit_A_RAE(double vit_A_RAE) {
		Vit_A_RAE = vit_A_RAE;
	}
	public double getRetinol() {
		return perValue(Retinol) ;
	}
	public void setRetinol(double retinol) {
		Retinol = retinol;
	}
	public double getAlpha_Carot() {
		return perValue(Alpha_Carot) ;
	}
	public void setAlpha_Carot(double alpha_Carot) {
		Alpha_Carot = alpha_Carot;
	}
	public double getBeta_Carot() {
		return perValue(Beta_Carot) ;
	}
	public void setBeta_Carot(double beta_Carot) {
		Beta_Carot = beta_Carot;
	}
	public double getBeta_Crypt() {
		return perValue(Beta_Crypt) ;
	}
	public void setBeta_Crypt(double beta_Crypt) {
		Beta_Crypt = beta_Crypt;
	}
	public double getLycopene() {
		return perValue(Lycopene) ;
	}
	public void setLycopene(double lycopene) {
		Lycopene = lycopene;
	}
	public double getLut_Zea() {
		return perValue(Lut_Zea) ;
	}
	public void setLut_Zea(double lut_Zea) {
		Lut_Zea = lut_Zea;
	}
	public double getVit_E() {
		return perValue(Vit_E) ;
	}
	public void setVit_E(double vit_E) {
		Vit_E = vit_E;
	}
	public double getVit_D_mcg() {
		return perValue(Vit_D_mcg) ;
	}
	public void setVit_D_mcg(double vit_D_mcg) {
		Vit_D_mcg = vit_D_mcg;
	}
	public double getViVit_D_IU() {
		return perValue(ViVit_D_IU) ;
	}
	public void setViVit_D_IU(double viVit_D_IU) {
		ViVit_D_IU = viVit_D_IU;
	}
	public double getVit_K() {
		return perValue(Vit_K) ;
	}
	public void setVit_K(double vit_K) {
		Vit_K = vit_K;
	}
	public double getFA_Sat() {
		return perValue(FA_Sat) ;
	}
	public void setFA_Sat(double fA_Sat) {
		FA_Sat = fA_Sat;
	}
	public double getFA_Mono() {
		return perValue(FA_Mono) ;
	}
	public void setFA_Mono(double fA_Mono) {
		FA_Mono = fA_Mono;
	}
	public double getFA_Poly() {
		return perValue(FA_Poly) ;
	}
	public void setFA_Poly(double fA_Poly) {
		FA_Poly = fA_Poly;
	}
	public double getCholestrl() {
		return perValue(Cholestrl) ;
	}
	public void setCholestrl(double cholestrl) {
		Cholestrl = cholestrl;
	}
	public double getGmWt_1() {
		return GmWt_1;
	}
	public void setGmWt_1(double gmWt_1) {
		GmWt_1 = gmWt_1;
	}
	public String getGmWt_Desc1() {
		return GmWt_Desc1;
	}
	public void setGmWt_Desc1(String gmWt_Desc1) {
		GmWt_Desc1 = gmWt_Desc1;
	}
	public double getGmWt_2() {
		return GmWt_2 ;
	}
	public void setGmWt_2(double gmWt_2) {
		GmWt_2 = gmWt_2;
	}
	public String getGmWt_Desc2() {
		return GmWt_Desc2;
	}
	public void setGmWt_Desc2(String gmWt_Desc2) {
		GmWt_Desc2 = gmWt_Desc2;
	}
	public double getRefuse_Pct() {
		return perValue(Refuse_Pct) ;
	}
	public void setRefuse_Pct(double refuse_Pct) {
		Refuse_Pct = refuse_Pct;
	}
	public String getFdGrp_Cd() {
		return FdGrp_Cd;
	}
	public void setFdGrp_Cd(String fdGrp_Cd) {
		FdGrp_Cd = fdGrp_Cd;
	}
	
	public void setType(int type){
		this.type = type;
	}
	
	public void setServing(int serving){
		this.serving = serving;
	}
	
	public double getUnitMapValue(){
		if(type==0){
			return 1;
		}else if(type ==1){
			return getGmWt_1();
		}else if(type ==2){
			return getGmWt_2();
		}
		
		return 0;
	}
	
	public String getValueByType(){
		String v = "100g";
		if(type ==1){
			return getGmWt_Desc1();
		}else if(type ==2){
			return getGmWt_Desc2();
		}
		
		return v;
	}
	
	public double perValue(double value){
		return formatNumber(value * (serving *getUnitMapValue() /100));
	}
	
	public static String[] getColumns(){
		String[] columns = new String[]{"NDB_No","Shrt_Desc","Water","Energ_Kcal","Protein","Lipid_Tot","Ash","Carbohydrt","Fiber_TD","Sugar_Tot","Calcium","Iron","Magnesium","Phosphorus","Potassium","Sodium","Zinc","Copper","Manganese","Selenium","Vit_C","Thiamin","Riboflavin","Niacin","Panto_Acid","Vit_B6","Folate_Tot","Folic_Acid","Food_Folate","Folate_DFE","Choline_Tot","Vit_B12","Vit_A_IU","Vit_A_RAE","Retinol","Alpha_Carot","Beta_Carot","Beta_Crypt","Lycopene","Lut_Zea","Vit_E","Vit_D_mcg","ViVit_D_IU","Vit_K","FA_Sat","FA_Mono","FA_Poly","Cholestrl","GmWt_1","GmWt_Desc1","GmWt_2","GmWt_Desc2","Refuse_Pct","FdGrp_Cd"};
		return columns;
	}
	
	private double formatNumber(double value){
		BigDecimal b = new BigDecimal(value);
		double f1 = b.setScale(2, BigDecimal.ROUND_HALF_DOWN).doubleValue();
		int fi = Double.valueOf(f1).intValue();
		if(f1-fi == 0){
			return fi;
		}else{
			return f1;
		}
	}
	
	public int getType() {
		return type;
	}
	public int getServing() {
		return serving;
	}
	
	
}
